# models.py in 'alerts' app
from django.db import models

class alert(models.Model):
    alert_id = models.AutoField(primary_key=True)
    alert_type = models.CharField(max_length=255)
    trigger_time = models.DateTimeField()
    device = models.ForeignKey('devices.Device', on_delete=models.CASCADE)
    level = models.CharField(max_length=50)

    def __str__(self):
        return f"Alert {self.alert_id}: {self.alert_type} for Device {self.device.device_name}"
